import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'

const UserIdKey = 'project-Management-Id'

const Name = 'project-Management-Name'

const TimeKey = 'project-Management-Time'

const IsAdministrators = 'project-Management-IsAdministrators'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getUserId() {
  return Cookies.get(UserIdKey)
}

export function setUserId(userId) {
  return Cookies.set(UserIdKey, userId)
}

export function removeUserId() {
  return Cookies.remove(UserIdKey)
}

export function getName() {
  return Cookies.get(Name)
}

export function setName(name) {
  return Cookies.set(Name, name)
}

export function removeName() {
  return Cookies.remove(Name)
}

// 获取时间戳
export function getTimeStamp() {
  return Cookies.get(TimeKey)
}
// 设置时间戳
export function setTimeStamp() {
  return Cookies.set(TimeKey, Date.now())
}

export function getIsAdministrators() {
  const value = localStorage.getItem(IsAdministrators)
  return value ? JSON.parse(value) : false
}

export function setIsAdministrators(isAdministrators) {
  return localStorage.setItem(
    IsAdministrators,
    JSON.stringify(isAdministrators)
  )
}

export function removeIsAdministrators() {
  return localStorage.removeItem(IsAdministrators)
}
